<?php
/**
 * 观察者类
 * @author 王志昂<wangzhiang@myhexin.com>
 * @create 2013-4-23 20:23:36
 */
class Subscribe_Push_Observer implements Subscribe_Observer
{
	private $_push;
	public function __construct(Subscribe_Push_Subject_Abstract $push)
	{
		$this->_push = $push;
		$this->_push->registerObserver($this);
	}
	
	public function update($style, $change)
	{
		$this->doUpdate($style, $change);
	}
	
	public function doUpdate($style, $change)
	{
		//获取推送用户表
		$userListObj = new Subscribe_Push_UserList($style);
		//获取推送的策略，可能有多个策略，策略是发送股灵通还是手机
		$pushStrategy = Zend_Registry::get('dzlalert')->strategy;
		foreach ($pushStrategy as $strategy) {
			$strategyClass = 'Subscribe_Push_Strategy_' . ucfirst($strategy);
			$pushStrategyObj = new $strategyClass();
			$pushStrategyObj->setStyle($style);
			$pushStrategyObj->setUserList($userListObj);
			$pushStrategyObj->setMessage($change);
			$pushStrategyObj->push();
		}
	}
}